package leetcode;

import java.util.ArrayList;
import java.util.List;

public class LeetCode53 {

    public int maxSubArray(int[] nums) {
        int maxAns = nums[0], pre = 0;
        for (int num : nums) {
            pre = Math.max(pre + num, num);
            maxAns = Math.max(pre, maxAns);
        }
        return maxAns;
    }
//------------------------------------------------------------------
}
